home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.001 / crossfir~ / eutl / xmalloc / test1.c < prev    next >
C/C++ Source or Header  |  1994-01-14  |  472b  |  33 lines

  1. #include "xmalloc.h"
  2. #include <stdio.h>
  3.  
  4. void toomuch()
  5. {
  6.   unsigned long v = 1 << 20;
  7.  
  8.   while(v<(1<<31)) {
  9.     xmalloc(v);
  10.     v <<= 1;
  11.   }
  12.   fprintf(stderr,"Failed to run out of memory??? Wow!\n");
  13.   exit(1);
  14. }
  15.  
  16. main() {
  17.   xmalloc_seterf(LongJmpPrintErrorFunction);
  18.   WITH_HANDLING
  19.     toomuch();
  20.   HANDLE {
  21.     BEGIN_MATCH;
  22.     XMATCH(xmalloc,nomem) {
  23.       printf("Correctly ran out of memory\n");
  24.     }
  25.     END_MATCH;
  26.   }
  27.   END_HANDLING;
  28.   exit(0);
  29. }
  30.  
  31.       
  32.       
  33.